package servic

import (
	"context"
	"fmt"
	"user-srv/basic/config"
	__ "user-srv/basic/proto"
	"user-srv/handler/model"
)

func (s *Server) VideoCheck(_ context.Context, in *__.VideoCheckReq) (*__.VideoCheckResp, error) {
	var video model.Video
	if err := video.CheckVideo(config.DB, int(in.Id), int(in.Status)); err != nil {
		return nil, fmt.Errorf("审核不通过")
	}
	config.DB.Where("status=?", in.Status).Find(&video)
	if video.Status != 1 {
		config.DB.Create(&model.Base{
			UserId: video.UserId,
			Title:  video.Title,
		})
	}
	return &__.VideoCheckResp{
		Id: int64(video.ID),
	}, nil
}
